import { reactive } from 'vue'
import type { FormRules } from 'element-plus'
export const rules = reactive<FormRules>({
  name: [
    { required: true, message: '请输入菜单唯一标识', trigger: 'blur' },
    {
      min: 2,
      max: 32,
      message: '菜单唯一标识长度应在2到32个字符之间',
      trigger: 'blur'
    },
    {
      pattern: /^[a-zA-Z]+$/,
      message: '菜单唯一标识仅允许输入英文字符',
      trigger: 'blur'
    }
  ],
  path: [
    { required: true, message: '请输入路径', trigger: 'blur' },
    {
      min: 2,
      max: 32,
      message: '路径长度应在2到32个字符之间',
      trigger: 'blur'
    }
  ],
  zhName: [
    { required: true, message: '请输入菜单名称', trigger: 'blur' },
    {
      min: 2,
      max: 24,
      message: '菜单名称长度应在2到24个字符之间',
      trigger: 'blur'
    }
  ]
})

export const permissionFormRules = reactive<FormRules>({
  name: [{ required: true, message: '请输入接口名称', trigger: 'blur' }],
  permission: [
    { required: true, message: '请输入接口权限', trigger: 'blur' },
    {
      pattern: /^[a-zA-Z\/:\-]+$/,
      message: '接口权限仅允许输入英字符、/、-、:',
      trigger: 'blur'
    }
  ],
  type: [{ required: true, message: '请选择接口类型', trigger: 'change' }]
})
